var t = getApp(),
  a = !0;

Page({
      data: {
        dicCode: [],
        dicContent: ['心脏', '胃', '大脑', '眼睛'],
        reports: [{
            detailFlag: 1,
            dateEm: 1,
            dateArr: [1, 2],
            currentIndex: 1,
            moreTextFlag: true,
            reportLabs: [{
                nmIndexLis: '心跳',
                nmResult: '偏高',
                valueLis: '50',
                casArray: [1],
                descRrs: 30,
                flagChart: 2,
              },
              {
                nmIndexLis: '心的大小',
                nmResult: '偏高',
                valueLis: 10,
                casArray: [1],
                descRrs: 20,
                flagChart: 1,
              },
              {
                nmIndexLis: '血液流速',
                nmResult: '偏高',
                valueLis: 100,
                casArray: [1],
                descRrs: 50,
                flagChart: 1,
              }
            ],
            cdIndexLis: 1,
            nmIndexLis: 1,
            images: [{
                imageUrl: '/assets/images/Wmedicine.png'
              },
              {
                imageUrl: '/assets/images/Wmedicine.png'
              },
              {
                imageUrl: '/assets/images/Wmedicine.png'
              }
            ],
            moreImgFlag: true,
            unfoldFlagOne: '收起',
            unfoldUrklOne: '/assets/images/Wmedicine.png',
            unfoldFlagTwo: '展开',
            unfoldUrklTwo: '/assets/images/Wmedicine.png'
          },
          {
            detailFlag: 1,
            dateEm: 1,
            dateArr: [1, 2],
            currentIndex: 1,
            moreTextFlag: true,
            reportLabs: [{
              nmIndexLis: '心跳',
              nmResult: '偏低',
              valueLis: '50',
              casArray: [1],
              descRrs: 30,
              flagChart: 2,
            },
            {
              nmIndexLis: '心的大小',
              nmResult: '偏低',
              valueLis: 10,
              casArray: [1],
              descRrs: 20,
              flagChart: 1,
            },
            {
              nmIndexLis: '血液流速',
              nmResult: '偏低',
              valueLis: 100,
              casArray: [1],
              descRrs: 50,
              flagChart: 1,
            }
            ],
            cdIndexLis: 1,
            nmIndexLis: 1,
            images: [{
              imageUrl: '/assets/images/Wmedicine.png'
            },
            {
              imageUrl: '/assets/images/Wmedicine.png'
            },
            {
              imageUrl: '/assets/images/Wmedicine.png'
            }
            ],
            moreImgFlag: true,
            unfoldFlagOne: '收起',
            unfoldUrklOne: '/assets/images/Wmedicine.png',
            unfoldFlagTwo: '展开',
            unfoldUrklTwo: '/assets/images/Wmedicine.png'
          }
      ],
    name: '心脏',
    loadingBoo: !0,
    moreBoo: !0,
    noneFlag: !1
  },
  previewImage: function(t) {
    console.log(t), a = !1;
    var e = this;
    wx.previewImage({
      current: t.target.dataset.imageurl,
      urls: e.data.reports[t.currentTarget.dataset.detailindex].imgArr
    });
  },
  getDetail: function(t) {
    console.log(t), this.data.reports[t.target.dataset.detailindex].detailFlag = !0,
      this.setData({
        reports: this.data.reports
      });
  },
  getData: function(t) {
    console.log(t), this.data.reports[t.currentTarget.dataset.detailindex].currentIndex = t.currentTarget.dataset.index,
      this.setData({
        reports: this.data.reports
      });
  },
  unfoldTwo: function(t) {
    "展开" == this.data.reports[t.currentTarget.dataset.detailindex].unfoldFlagTwo ? (this.data.reports[t.currentTarget.dataset.detailindex].unfoldFlagTwo = "收起",
        this.data.reports[t.currentTarget.dataset.detailindex].unfoldUrklTwo = "/assets/images/now02.png") : (this.data.reports[t.currentTarget.dataset.detailindex].unfoldFlagTwo = "展开",
        this.data.reports[t.currentTarget.dataset.detailindex].unfoldUrklTwo = "/assets/images/now.png"),
      this.data.reports[t.currentTarget.dataset.detailindex].images.forEach(function(t) {
        t.moreImgFlag = !t.moreImgFlag;
      }), this.setData({
        reports: this.data.reports
      });
  },
  unfold: function(t) {
    console.log(t), "展开" == this.data.reports[t.currentTarget.dataset.detailindex].unfoldFlagOne ? (this.data.reports[t.currentTarget.dataset.detailindex].unfoldFlagOne = "收起",
        this.data.reports[t.currentTarget.dataset.detailindex].unfoldUrklOne = "/assets/images/now02.png") : (this.data.reports[t.currentTarget.dataset.detailindex].unfoldFlagOne = "展开",
        this.data.reports[t.currentTarget.dataset.detailindex].unfoldUrklOne = "/assets/images/now.png"),
      this.data.reports[t.currentTarget.dataset.detailindex].reportLabs.forEach(function(t) {
        t.moreTextFlag = !t.moreTextFlag;
      }), this.setData({
        reports: this.data.reports
      });
  },
  tabFun: function(t) {
    var a = t.target.dataset.id,
      e = t.target.dataset.name;
    this.setData({
        curHdIndex: a,
        name: e,
        loadingBoo: !0,
        moreBoo: !0,
        noneFlag: !1,
        into_id: t.target.id
      }),
      // wx.showLoading({
      //     title: "加载中...",
      //     mask: !0
      // }), 
      this.getTestMsg();
  },
  onLoad: function(t) {
    // this.setData({
    //   teamId: t.teamId || ""
    // });
  },
  onShow: function(e) {
    // if (a) {
    //   var r = this,
    //     o = [],
    //     n = [];
    //   r.setData({
    //     noneFlag: !1,
    //     moreBoo: !0
    //   })
    // , 
    // wx.showLoading({
    //     title: "加载中...",
    //     mask: !0
    // });
    //   var s = wx.getStorageSync("log");
    //   wx.request({
    //     url: t.globalData.loginDic + "comdicbase?code=210000",
    //     success: function(t) {
    //       if (200 == t.data.code)
    //         for (var a in t.data.data) o.push(a), n.push(t.data.data[a]);
    //       r.setData({
    //         dicCode: o,
    //         dicContent: n,
    //         token: s
    //       }), r.data.curHdIndex || r.setData({
    //         curHdIndex: o[0],
    //         name: n[0],
    //         into_id: "all" + o[0]
    //       }), r.getTestMsg();
    //     }
    //   });
    // }
    // a = !0;
  },
  more: function(a) {
    var e = this,
      r = e.data.token,
      o = wx.getStorageSync("patientId") || "";
    console.log(o + "_" + r);
    var r = o + "_" + r + e.data.teamId,
      n = wx.getStorageSync("flag") || "";
    e.data.moreBoo && e.data.loadingBoo && (this.setData({
      loadingBoo: !1
    }), wx.request({
      url: t.globalData.patient + "patient/report/list/" + r + "/" + e.data.curHdIndex + "/" + e.data.currentResult + "/" + n,
      success: function(a) {
        if (console.log(a), 200 == a.data.code) {
          if (null == a.data.data.reports) return void e.setData({
            moreBoo: !1,
            loadingBoo: !0
          });
          var r = e.data.reports;
          a.data.data.reports.forEach(function(a) {
            a.dateEm = t.getDate(a.dateEm), a.dateArr = a.dateEm.split("-"), a.currentIndex = 1,
              a.unfoldFlagOne = "展开", a.unfoldUrklOne = "/assets/images/now.png", a.unfoldFlagTwo = "展开",
              a.unfoldUrklTwo = "/assets/images/now.png", a.detailFlag = !1;
            var e = [];
            a.images.length > 0 && a.images.forEach(function(t) {
              e.push(t.imageUrl);
            }), a.imgArr = e, a.reportLabs.forEach(function(t) {
              t.moreTextFlag = !1, t.moreImgFlag = !1, "text" == t.valType && (t.casArray = t.valEnum.split("|"),
                t.valueLis = parseFloat(t.valueLis));
            }), r.push(a);
          }), e.setData({
            loadingBoo: !0,
            reports: r,
            currentResult: a.data.data.page.nextResult
          });
        }
      }
    }));
  },
  getTestMsg: function() {
    var a = this,
      e = a.data.token,
      r = wx.getStorageSync("patientId") || "";
    console.log(r + "_" + e);
    var e = r + "_" + e + a.data.teamId,
      o = wx.getStorageSync("flag") || "",
      n = [];
    wx.request({
      url: t.globalData.patient + "patient/report/list/" + e + "/" + a.data.curHdIndex + "/0/" + o,
      success: function(e) {
        if (wx.hideLoading(), 200 == e.data.code) {
          if (console.log(e.data), null == (n = e.data.data.reports)) return void a.setData({
            noneFlag: !0,
            reports: []
          });
          n.forEach(function(a, e) {
            a.detailFlag = e <= 2, a.dateEm = t.getDate(a.dateEm), a.dateArr = a.dateEm.split("-"),
              a.currentIndex = 1, a.unfoldFlagOne = "展开", a.unfoldUrklOne = "/assets/images/now.png",
              a.unfoldFlagTwo = "展开", a.unfoldUrklTwo = "/assets/images/now.png";
            var r = [];
            a.images.length > 0 && a.images.forEach(function(t) {
              r.push(t.imageUrl);
            }), a.imgArr = r, a.reportLabs.forEach(function(t) {
              t.moreTextFlag = !1, t.moreImgFlag = !1, "text" == t.valType && (t.casArray = t.valEnum.split("|"),
                t.valueLis = parseFloat(t.valueLis));
            });
          }), a.setData({
            reports: n,
            currentResult: e.data.data.page.nextResult
          });
        }
      }
    });
  }
});